package com.chenye.design.strategy;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther:chenye
 * @Data:2018/11/1
 * @Description:
 */
public class Context {

    private Car car;

    private List<Car> cars = new ArrayList<>();

    public void runCar(Car car) {
        car.run();
    }
    public void runCars() {
        for(Car car : cars){
            car.run();
        }
    }
    public void addCar(Car car) {
        cars.add(car);
    }
    public void removeCar(Car car) {
        cars.remove(car);
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    public static void main(String[] args) {
        Context context = new Context();
        context.addCar(new BCCar());
        context.addCar(new BMWCar());
        context.runCars();
    }
}
